package code;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class SetZeroes_day03 {
    public static void main(String[] args) {
        int[][] matrix={{0,1,3},{1,2,3},{4,5,6}};

        //记录0坐标
        class address{
            int x;
            int y;
            public address(int x, int y) {
                this.x = x;
                this.y = y;
            }

        }

        List<address> addressList=new ArrayList<address>();
        for(int i=0;i<matrix.length;i++){
            for(int j=0;j<matrix[i].length;j++){
                if(matrix[i][j]==0){
                    address address=new address(i,j);
                    addressList.add(address);
                }
            }
        }
        for(int i=0;i<addressList.size();i++){
            address address=addressList.get(i);
            for(int j=0;j<matrix[0].length;j++){
                int y = address.y;
                int x = address.x;
                for(int k=0;k<matrix.length;k++){
                    matrix[k][y]=0;
                }
                for(int k=0;k<matrix[0].length;k++){
                    matrix[x][k]=0;
                }
            }
        }
        System.out.println(Arrays.deepToString(matrix));

    }
}
